Python Scripting
To automate the simulation, you can use Python scripting with OMSimulator. More information about the python api can be found in the User Guide.from OMSimulator import OMSimulator
oms = OMSimulator()
oms.newModel("model")
oms.addSystem("model.root", oms.system_sc)
oms.addSubModel("model.root.BouncingBall", "BouncingBall.fmu")
oms.setResultFile("model", "results.mat")
oms.instantiate("model")
oms.initialize("model")
oms.simulate("model")
oms.terminate("model")
oms.delete("model")
Run the script using:OMSimulatorPython3.bat <script>.py
Example output:info: maximum step size for 'model.root': 0.001000
info: Result file: results.mat (bufferSize=1)
info: Final Statistics for 'model.root':
NumSteps = 552 NumRhsEvals = 557 NumLinSolvSetups = 32
NumNonlinSolvIters = 556 NumNonlinSolvConvFails = 0 NumErrTestFails = 1
The result file can be plotted using OMEdit, OMPlot, or any other tool that supports .mat or .csv files. OpenModelica includes OMPlot, a simple tool for quickly visualizing result files:OMPlot.exe --plotAll --filename=results.mat